<% content_for :page_title do %>
  <%= t('spree.active_sale.title.list') %>
<% end %>

<% content_for :page_actions do %>
  <li>
    <%= button_link_to t('spree.active_sale.link.new'), new_object_url, :icon => 'icon-plus', :id => 'admin_new_active_sale_link' %>
  </li>
<% end %>

<div id="new_active_sale" data-hook></div>

<table class="index sortable" id='listing_active_sales' data-hook data-sortable-link="<%= update_positions_admin_active_sales_url %>">
  <colgroup>
    <col style="width: 85%">
    <col style="width: 15%">
  </colgroup>
  <thead>
    <tr data-hook="active_sales_header">
      <th><%= t('spree.active_sale.active_record.name') %></th>
      <th class="actions"></th>
    </tr>
  </thead>
  <tbody>
    <% @active_sales.each do |active_sale| %>
      <tr id="<%= spree_dom_id active_sale %>" data-hook="active_sales_row" class="<%= cycle('odd', 'even')%>">
        <td>
          <span class="handle"></span>&nbsp;
          <%= active_sale.name %>
        </td>
        <td class="actions">
          <%= link_to_edit active_sale.id, :no_text => true %>
          <%= link_to_delete active_sale, :no_text => true %>
        </td>
      </tr>
    <% end %>
  </tbody>
</table>

<%= paginate @active_sales %>

<% content_for :sidebar_title do %>
  <%= Spree.t(:search) %>
<% end %>

<% content_for :sidebar do %>
  <div class="box align-center" data-hook="admin_active_sales_index_search">    
    <%= search_form_for [:admin, @search] do |f| %>
      <div class="field">
        <%= f.label Spree.t(:name) %> <br>
        <%= f.text_field :name_cont, :class => 'fullwidth' %>
      </div>
      <div data-hook="admin_active_sales_index_search_buttons">
        <%= button Spree.t(:search), 'icon-search' %>
      </div>
    <% end %>
  </div>
<% end %>
